package com.woke.adapter;

import java.util.ArrayList;
import java.util.List;

import com.zhongcai.online.R;
import com.woke.data.Data_bindcarlist;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class Bankedadapter extends BaseAdapter{
	private LayoutInflater mInflater;
	private List<Data_bindcarlist> datalist;

	public Bankedadapter(LayoutInflater minflater,	ArrayList<Data_bindcarlist> datalist) {
		this.mInflater = minflater;
		this.datalist = datalist;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datalist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	class Holder {
//		ImageView mIicon;
		TextView mTbankname;
		TextView mTbankcarno;
		TextView mTcardtype;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if(convertView == null){
			holder = new Holder();
			convertView = mInflater.inflate(R.layout.item_adater_mybank, null);
//			holder.mIicon = (ImageView) convertView.findViewById(R.id.item_myblind_bankicon);
			holder.mTbankname = (TextView) convertView.findViewById(R.id.item_myblind_title);
			holder.mTbankcarno = (TextView) convertView.findViewById(R.id.item_myblind_cardno);
			holder.mTcardtype = (TextView) convertView.findViewById(R.id.item_myblind_cardtype);
			convertView.setTag(holder);
		}else{
			 holder = (Holder) convertView.getTag();
		}
		
		Data_bindcarlist list = datalist.get(position);
		if(list.brname.equals("")){
			holder.mTbankname.setText("银行");
		}else{
			holder.mTbankname.setText(list.brname);
		}
		holder.mTbankcarno.setText(list.cardno.substring(0, 4)+"    "+"***"+"    "+"***"+"    "+"***"+"    "+list.cardno.substring(list.cardno.length()-3, list.cardno.length()));
		if(list.type.equals("0")){
			holder.mTcardtype.setText("信用卡");
		}else{
			holder.mTcardtype.setText("储蓄卡");
		}
		
//		holder.mTbankname.setText(list.card_name);
//		holder.mTbankcarno.setText(list.card_top + " "+"***"+" "+"***"+" "+list.card_last);
//		holder.mTcardtype.setText(list.card_name);
//		
		
		return convertView;
	}

}
